Skip to content

refactor(plan-selection): move files into the search/ and cost/ layout (move only) - #920

Merged
zzylol merged 1 commit into
mainfrom
refactor/plan-selection-layout
Oct 23, 2026
Merged

zzylol merged 1 commit into
mainfrom
refactor/plan-selection-layout

Conversation

@zzylol

@zzylol zzylol commented Oct 23, 2026

Copy link
Copy Markdown
Contributor

Part of #879

Why

asap-plan-selection grew three searches (the current whole-workload search, the memo brute force and the memo MILP) and the memo's per-node pricing under one pass/subexpr/ directory, next to cost files at the crate root. This is step 1 of the approved layout: a search/ tree by search algorithm and a cost/ tree for everything that prices. Moving the files first, with no logic change, keeps the later splits (of lib.rs and milp.rs) reviewable as small diffs.

What

Files move into search/legacy, search/memo (with rules/), search/milp and cost/. Module and use paths are updated. Nothing else changes: no logic, no item renames, and the crate root's public paths stay the same.

How

  • git mv per the table below, plus three small new mod.rs files (search/legacy, search/memo/rules, search/milp).
  • Relative super:: paths in the moved files are rewritten as crate:: paths.
  • Items that now cross a module boundary they did not cross before are pub(crate). That is every pub(super) in the moved files, plus a few private helpers that sibling modules used through super:: (in brute_force, per_node, measured).
  • #![allow(dead_code)] is added to cost/per_node.rs and search/milp/mod.rs. They used to inherit it from the memo module.
  • lib.rs declares pub mod search; with pub use search as pass; and pub use search::legacy::pane_sharing;, so asap_plan_selection::pass::* and asap_plan_selection::pane_sharing resolve as before and no other crate changes.
  • Doc links and file paths in docs point at the new files.
Before After
pass/mod.rs search/mod.rs
pass/stage1_to_stage3.rs search/legacy/stage1_to_stage3.rs
pass/components.rs search/legacy/components.rs
pass/interchangeable.rs search/legacy/interchangeable.rs
pass/query_candidates.rs search/legacy/query_candidates.rs
pane_sharing.rs search/legacy/pane_sharing.rs
pass/subexpr/mod.rs search/memo/mod.rs
pass/subexpr/groups.rs search/memo/groups.rs
pass/subexpr/capability.rs search/memo/rules/capability.rs
pass/subexpr/windows.rs search/memo/rules/windows.rs
pass/subexpr/scans.rs search/memo/rules/scans.rs
pass/subexpr/search.rs search/memo/brute_force.rs
pass/subexpr/milp.rs search/milp/model.rs
pass/subexpr/coefficients.rs search/milp/coefficients.rs
pass/subexpr/pricing.rs cost/per_node.rs
measured_operation_costs.rs cost/measured.rs
cost/analytical_cost.rs cost/analytical.rs
cost/physical_operator_statistics.rs cost/operator_statistics.rs

All paths are under crates/plan-selection/src/.

Key code interfaces added / modified

None (paths only). Public paths kept: asap_plan_selection::pass::* (now an alias of search), asap_plan_selection::pane_sharing, and every crate-root re-export. The public cost submodules are renamed with their files (cost::analytical, cost::operator_statistics); no other crate uses them.

Major algorithm changes

None.

Before this PR

The memo search, its MILP and its per-node pricing lived together in pass/subexpr/; cost files were split between the crate root and cost/.

After this PR

Each search lives in its own directory under search/, and everything that prices lives under cost/. Splitting lib.rs and milp.rs comes in a later PR.

Verification

  • cargo test -p asap-plan-selection: all tests pass.
  • cargo check --workspace --tests: dependent crates build unchanged.
  • cargo fmt --check and cargo clippy -p asap-plan-selection --all-targets -- -D warnings: clean.
  • git diff -M --stat: every file is detected as a rename. The remaining line changes are use and module paths.
  • cargo doc -p asap-plan-selection --document-private-items: the same unresolved links as before the move, none new.

Move only: search/legacy (the current search), search/memo (groups, rules,
brute force), search/milp (model, coefficients), cost/per_node and
cost/measured; module and use paths updated, items crossing the new
module boundaries made pub(crate). The crate root's public paths are
unchanged (pass, pane_sharing and the re-exports).
@zzylol zzylol added optimizer Workload optimization and plan selection refactor labels Oct 23, 2026
@zzylol
zzylol merged commit 65655b6 into main Oct 23, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

optimizer Workload optimization and plan selection refactor

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant